package Dao.impl;/*
 *86180
 *2021/10/4
 *12:05
 */

import Dao.OrganDao;
import entity.Organ;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import util.DruidUtil;

import java.sql.SQLException;
import java.util.List;

public class OrganDaoImpl implements OrganDao {
    private QueryRunner queryRunner=new QueryRunner();
    @Override
    public List<Organ> selectAll() {
        try {
            return queryRunner.query(DruidUtil.getConnection(), "select * from organ;",new BeanListHandler<>(Organ.class));
        } catch (SQLException e) {
            throw new RuntimeException(e.getMessage()+"查询所有organ机构异常");
        }
    }
}
